<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <base href="__STATIC__/">
    <link href="css/Sellerber.css" type="text/css"  rel="stylesheet" />
    <link href="css/bkg_ui.css" type="text/css"  rel="stylesheet" />
    <script src="js/jquery-1.9.1.min.js" type="text/javascript" ></script>
    <script src="js/layer/layer.js" type="text/javascript"></script>
    <!--[if lt IE 9]>
    <script src="js/html5shiv.js" type="text/javascript"></script>
    <script src="js/respond.min.js"></script>
    <script src="js/css3-mediaqueries.js"  type="text/javascript"></script>
    <![endif]-->
    <title>新品列表</title>
</head>
<body>
<div class="margin" id="page_style">
    <!--列表展示-->
    <div class="h_products_list clearfix" id="Sellerber">
        <div class="Sellerber_left menu" id="menuBar">
            <div class="show_btn" id="rightArrow"><span></span></div>
            <div class="side_title"><a title="隐藏" class="close_btn"><span></span></a></div>

        </div>
        <div class="list_Exhibition list_show padding15">
            <div class="operation clearfix mb15  searchs_style">
                <button class="btn button_btn btn-danger" type="button" onclick=""><i class="fa fa-trash-o"></i>&nbsp;删除</button>
                <div class="search  clearfix">
                    <label class="label_name">搜索：</label><input name="" type="text"  class="form-control col-xs-5"/><button class="btn button_btn bg-deep-blue " onclick=""  type="button"><i class="fa  fa-search"></i>&nbsp;搜索</button>
                </div>
            </div>
            <div class=" datalist_show">
                <div class="datatable_height confirm">
                    <table class="table table_list table_striped table-bordered" id="">
                        <thead>
                        <tr>
                            <th width="25"><label><input type="checkbox" class="ace"><span class="lbl"></span></label></th>
                            <th width="100">商品名称</th>
                            <th  width="80px">商品品牌</th>
                            <th width="80px">商品分类</th>
                            <th width="100px">特价价格</th>
                            <th width="100px">适合人群</th>
                            <th width="150px">开始时间</th>
                            <th width="150px">结束时间</th>
                            <th width="80px">状态</th>
                            <th width="250px">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                       <?php foreach($data as $val){?>
                           <tr>
                               <td><label><input type="checkbox" class="ace"><span class="lbl"></span></label></td>
                               <td><?= $val['g_name']?></td>
                               <td><?= $val['b_name']?></td>
                               <td> <?= $val['c_name']?></td>
                               <td class="displayPart" displayLength="60"><?= $val['tj_price']?></td>
                               <?php if($val['g_sex'] == 1){?>
                               <td>女</td>
                               <?php }else{?>
                               <td>男</td>
                               <?php }?>
                               <td>{$val.tj_addtime|date="Y-m-d H:i:s",###}</td>
                               <td>{$val.tj_endtime|date="Y-m-d H:i:s",###}</td>
                               <td class="td-status">
                                  <?php if($val['g_state']==1){ ?> 
                                  <span class="label label-success radius">已发布</span>
                                  <?php }else { ?>
                                     <span class="label label-defaunt radius">待发布</span>
                                  <?php }?>
                              </td>
                               <td class="td-manage">
                              <?php if($val['g_state']==1){ ?>
                                <a onClick="member_stop(this,'{$val.g_id}')"  href="javascript:;" title="下架"  class="btn btn-xs btn-status">下架</a>
                              <?php }else { ?>
                                <a onClick="member_stop(this,'{$val.g_id}')"  href="javascript:;" title="发布"  class="btn btn-xs">发布</a>
                              <?php }?>
                                   <a title="删除" href="javascript:;"  onclick="member_del(this,'{$val.g_id}')" class="btn btn-xs btn-delete" >删除</a>
                               </td>
                           </tr>
                        <?php }?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<p>
    {$data->render()}
</p>
</body>
</html>
<script>
    function generateOrders(id){
  window.location.href = "Brand_detailed.html?="+id;
};
/*品牌-查看*/
function member_show(title,url,id,w,h){
  layer_show(title,url,w,h);
}
/*品牌-停用*/
/*产品-停用*/
function member_stop(obj,g_id){
  // console.log(obj)
   if($(obj).html()=='下架'){
     layer.confirm('确认要下架该品牌吗？',function(index){
    $.ajax({
      type: 'GET',
      url: '{:url("Yang/edit")}',
      data:{g_id:g_id},
      success: function (res) {
      $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" class="btn btn-xs " onClick="member_stop(this,'+g_id+')" href="javascript:;" title="发布">发布</a>');
      $(obj).parents("tr").find(".td-status").html('<span class="label label-defaunt radius">待发布</span>');
      $(obj).remove();
      layer.msg('已下架!',{icon: 5,time:1000});       
      }         
    })
  });
  } else{
    layer.confirm('确认要发布改该品牌吗？',function(index){
    $.ajax({
      type: 'GET',
      url: '{:url("Yang/edit")}',
      data:{g_id:g_id},
      success:function(res){
      $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" class="btn btn-xs btn-status" onClick="member_stop(this,'+g_id+')" href="javascript:;" title="下架">下架</a>');
      $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已发布</span>');
      $(obj).remove();
      layer.msg('已发布!',{icon: 6,time:1000});
     }
    })
  });
  }
}
/*产品-启用*/
/*产品-编辑*/
// function member_edit(title,url,g_id,w,h){
//  layer_show(title,url,w,h);
// }
/*产品-删除*/  
    $(function () { $(".displayPart").displayPart();  });
    /*删除*/
    function member_del(obj,g_id){
      layer.confirm('确认要删除吗？',function(index){
           $.ajax({
            type: 'GET',
            url: '{:url("yang/new_goods_list_del")}',
            data:{g_id:g_id},
            dataType:'json',
            success: function (data) {
              if(data == 1){

                $(obj).parents("tr").remove();
                layer.msg('已删除 !',{icon:1,time:1000});
              } else if (data == 0){
                console.log(data.msg);
                layer.msg('删除失败 !',{icon:2,time:1000});
              } 
          } 
      })
    })                    
}
  //设置时间
laydate({
    elem: '#start',
    event: 'focus' 
});
</script>
